/**
 * Description:
 * Class Name:ObjectsTest
 * Date:2022/2/19 12:26
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第7章_Java基础类库._7_3_常用类.操作对象的Objects工具类;

import java.util.Objects;

public class ObjectsTest {
    // 定义一个obj变量，默认值是null
    static ObjectsTest obj;

    public static void main(String[] args) {
        System.out.println(Objects.hashCode(obj));
        System.out.println(Objects.toString(obj));              // 不会引发错误信息
        // 但下面的语句会引发错误
//        System.out.println(obj.toString());
        System.out.println(Objects.requireNonNull(obj, "obj参数不能为空"));   // 引发错误并给出错误信息

    }
}
